﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sy4_1
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void txtMemory_TextChanged(object sender, EventArgs e)
        {
            try
            {
                int memory = int.Parse(txtMemory.Text);
                if (memory <= 0)
                {
                    MessageBox.Show("内存大小必须大于0");
                    txtMemory.Clear();
                    txtMemory.Focus();
                }
            }
            catch
            {
                MessageBox.Show("输入有误，请输入数字");
                txtMemory.Clear();
                txtMemory.Focus();
            }
        }

        private void btnConfirm_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();

            string brand = cboBrand.Text;
            string type = "";
            if (rdoLaptop.Checked) type = "笔记本";
            if (rdoDesktop.Checked) type = "台式机";
            if (rdoTablet.Checked) type = "平板电脑";

            string cpu = "";
            if (rdoCore.Checked) cpu = "酷睿";
            if (rdoPentium.Checked) cpu = "奔腾";
            if (rdoAMD.Checked) cpu = "AMD";

            string memory = txtMemory.Text + "G内存";

            string peripherals = "";
            if (chkHDD.Checked) peripherals += "移动硬盘\n";
            if (chkDVD.Checked) peripherals += "外置DVD光驱\n";
            if (chkWireless.Checked) peripherals += "无线键鼠套装\n";

            listBox1.Items.Add(brand);
            listBox1.Items.Add(type);
            listBox1.Items.Add(memory);
            listBox1.Items.Add(cpu);
            listBox1.Items.Add(peripherals);
        }

    }
}
